/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nodes;

import java.io.IOException;
import java.util.ArrayList;
import novoRIP.*;

/**
 *
 * @author Diego
 */
public class Node3 {

    private static final RIP_Constants constants = new RIP_Constants();
    private int nodeId;
    private int[][] distanceTable;
    private clienteTCP clientAux;
    private serverMulthreadTCP server;
    private ArrayList<clienteTCP> clientList;

    public Node3(int nodeIdParam, ArrayList<Integer> socketsPortList) throws IOException {
        nodeId = nodeIdParam;
        clientList = new ArrayList<clienteTCP>();
        initTable();

        for (int i : socketsPortList) {
            clientList.add(new clienteTCP("localhost", i, "testaaaannndo\n"));
        }
    }

    private void rtInit0() {
    }

    private void initTable() {
        distanceTable = new int[4][4];
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                distanceTable[i][j] = 999;
            }
        }
    }

    public void initNodeTable() {
        switch (nodeId) {
            case 0:
                //inicializa tabela node 0
                break;
            case 1:
                //inicializa tabela node 1
                break;
            case 2:
                //inicializa tabela node 2
                break;
            case 3:
                //inicializa tabela node 3
                break;
            default:
            //messagem erros?

        }



//        distanceTable = new int[4][4];
//        for (int i = 0; i < 4; i++) {
//            for (int j = 0; j < 4; j++) {
//                distanceTable[i][j] = 999;
//            }
//        }
//    }
    }

    public void updateNodeTable(pacote pkg) {
        switch (nodeId) {
            case 0:
                //pkg lalalala
                //inicializa tabela node 0
                break;
            case 1:
                //inicializa tabela node 1
                break;
            case 2:
                //inicializa tabela node 2
                break;
            case 3:
                //inicializa tabela node 3
                break;
            default:
            //messagem erros?

        }
    }




    //    public void rtinit() {
//    }
//
//    public void rtupdate(rtpkt rcvdpkt) {
//    }
//
//    //Metodo para exibir
//    public void printdt(distance_table dtptr) {
//    //public void printdt(distance_table dtptr) {
//        System.out.println("                via     \n");
//        System.out.println("   D0 |    1     2    3 \n");
//        System.out.println("  ----|-----------------\n");
//        System.out.println("     1|  " + dtptr.costs[1][1] + dtptr.costs[1][2] + dtptr.costs[1][3] + "\n");
//        System.out.println("dest 2|  " + dtptr.costs[2][1] + dtptr.costs[2][2] + dtptr.costs[2][3] + "\n");
//        System.out.println("     3|  " + dtptr.costs[3][1] + dtptr.costs[3][2] + dtptr.costs[3][3] + "\n");
//
//
//    }
}
